package hanjia;

import suanfa.ListNode;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2025/2/10-下午2:46
 * Since  :   1.0
 * Version:   1.0
 */
public class LeetCode24 {

    public ListNode swapPairs(ListNode head) {
        ListNode sentinel=new ListNode();
        sentinel.next=head;
        ListNode current=sentinel;
        while (current.next!=null&&current.next.next!=null){
            ListNode pre=current.next;
            ListNode next=pre.next;
            ListNode moreNext=next.next;
            current.next=next;
            next.next=pre;
            pre.next=moreNext;
            current=pre;
        }
        return sentinel.next;

    }
}
